package com.demo12;

public class Truck {
    private String brand;//品牌
    private Double weight;//承受吨位

    //构造函数处理
    public Truck() {
    }

    public Truck(String brand, Double weight) {
        this.brand = brand;
        this.weight = weight;
    }
    //属性设置 get/set
    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public Double getWeight() {
        return weight;
    }

    public void setWeight(Double weight) {
        this.weight = weight;
    }
    //重写方法
    @Override
    public String toString() {
        return "Truck{" +
                "brand='" + brand + '\'' +
                ", weight=" + weight +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Truck truck = (Truck) o;

        if (brand != null ? !brand.equals(truck.brand) : truck.brand != null) return false;
        return weight != null ? weight.equals(truck.weight) : truck.weight == null;
    }

    @Override
    public int hashCode() {
        int result = brand != null ? brand.hashCode() : 0;
        result = 31 * result + (weight != null ? weight.hashCode() : 0);
        return result;
    }
}
